From e201a8949c40ff1456e219d87a67313ee54dfe52 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 10 Apr 2018 15:10:38 +0100 Subject: [PATCH] warn in 2015, error in 2018 --- src/cargo/ops/cargo_install.rs | 16 ++++++++++++---- tests/testsuite/install.rs | 18 +++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 9984c3952..7987eb1e7 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -235,10 +235,18 @@ fn install_one( if from_cwd { match pkg.manifest().edition() { - Edition::Edition2015 => (), - Edition::Edition2018 => { - config.shell().warn("To build the current package use 'cargo build', to install the current package run `cargo install --path .`")?; - }, + Edition::Edition2015 => + config.shell().warn("To build the current package use `cargo build`, to install the current package run `cargo install --path .`")? + , + Edition::Edition2018 => + bail!( + "To build the current package use `cargo build`, \ + to install the current package run `cargo install --path .`, \ + otherwise specify a crate to install from \ + crates.io, or use --path or --git to \ + specify alternate source" + ) + , } }; diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 3224f269f..8e3baa8cf 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1009,7 +1009,11 @@ fn installs_from_cwd_by_default() { assert_that( cargo_process("install").cwd(p.root()), - execs().with_status(0), + execs().with_status(0).with_stderr_contains( + "\ +warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .` +", + ), ); assert_that(cargo_home(), has_installed_exe("foo")); } @@ -1039,13 +1043,13 @@ fn installs_from_cwd_with_2018_warnings() { assert_that( cargo_process("install").cwd(p.root()).masquerade_as_nightly_cargo(), - execs().with_status(0).with_stderr_contains( - "\ -warning: To build the current package use 'cargo build', to install the current package run `cargo install --path .` -", - ), + execs().with_status(101).with_stderr_contains( + "error: To build the current package use `cargo build`, \ + to install the current package run `cargo install --path .`, \ + otherwise specify a crate to install from crates.io, \ + or use --path or --git to specify alternate source\ + "), ); - assert_that(cargo_home(), has_installed_exe("foo")); } #[test] -- 2.30.2